import request from "../untils/request";

// 注册时获取验证码
export const apiGetCode = (params: any) => {
    request({
        url: "/sms_code/send_sms_code",
        method: "get",
        params: params
    })
}

// 后台人员用户注册接口
export const userRegister = (params: any) => {
    return request({
        url: "/system/register",
        method: "post",
        data: params
    })
}

// 登录时获取图片验证码
export const getImgCode = (params: any) => {
    return request({
        url: "/captcha/generateCaptcha?vl=4&fs=25&w=140&h=40&method=adminLogin",
        method: "get",
        responseType: 'arraybuffer',
        params: params
    })
}

// 后台人员登录接口
export const adminLogin = (params: any) => {
    return request({
        url: "/adminLogin",
        // withCredentials: true,
        method: "post",
        data: params
    })
}

// 获取登录人信息接口
export const getLoginUserInfo = (params: any) => {
    return request({
        url: "/system/getLoginUserInfo",
        method: "get",
        // responseType: 'arraybuffer',
        params: params
    })
}



// 获取图片
export const getImgUrl = (params: any) => {
    return request({
        url: "/download/view",
        method: "get",
        responseType: 'arraybuffer',
        params: params
    })
}


// 获取所有菜单接口
export const getAllMenu = (params: any) => {
    return  request({
        url: "/admin/menu/list",
        method: "get",
        withCredentials: true,
        params: params
    })
}

// 根据权限获取登录人员菜单接口
export const apiGetMenu = (params: any) => {
    return request({
        url: "/admin/menu/getMenusByLoginUser",
        method: "get",
        // responseType: 'arraybuffer',
        params: params
    })
}


// 新增菜单
export const addMenus = (params: any) => {
    return request({
        url: "/admin/menu/add",
        method: "post",
        data: params
    })
}

// 删除菜单
export const deleteMenus = (params: any) => {
    return request({
        url: "/admin/menu/delete",
        method: "post",
        data: params
    })
}

// 修改菜单信息
export const updateMenusInfo = (params: any) => {
    return request({
        url: "/admin/menu/edit",
        method: "post",
        data: params
    })
}

// 获取所有角色列表
export const getAllRoles = (params: any) => {
    return request({
        url: "/admin/role/list",
        method: "get",
        params: params
    })
}

// 删除角色信息
export const deleteRoleInfo = (params: any) => {
    return request({
        url: "/admin/role/delete",
        method: "post",
        data: params
    })
}

// 根据id获取角色权限
export const getRoleInfoById = (params: any) => {
    return request({
        url: "/admin/role/getRoleId",
        method: "get",
        params: params
    })
}

// 修改角色信息
export const updateRoleInfo = (params: any) => {
    return request({
        url: "/admin/role/edit",
        method: "post",
        data: params
    })
}

// 新增角色信息
export const addRoleInfo = (params: any) => {
    return request({
        url: "/admin/role/add",
        method: "post",
        data: params
    })
}


// 分页查看商户列表
export const getUserInfo = (params: any) => {
    return request({
        url: "/admin/user/list",
        method: "post",
        data: params
    })
}

// 冻结商户信息
export const freezeUser = (params: any) =>{
    return request({
        url: "/admin/user/frozenAccount",
        method: "post",
        data: params
    })
}

// 解冻商户信息 /admin/user/unFrozenAccount
export const unFreezeUser = (params: any) =>{
    return request({
        url: "/admin/user/unFrozenAccount",
        method: "post",
        data: params
    })
}

// 分页查看日志列表
export const getLogList = (params: any) =>{
    return request({
        url: "/system/operator_log_list",
        method: "post",
        data: params
    })
}

// 清空日志
export const deleteAllList = (params: any) =>{
    return request({
        url: "/system/delete_all_operator_log",
        method: "post",
        data: params
    })
}

//删除日志
export const deleteList = (params: any) =>{
    return request({
        url: "/system/delete_operator_log",
        method: "post",
        data: params
    })
}

// 获取备份数据列表
export const getDataBack = (params: any) => {
    return request({
        url: "/admin/database_bak/list",
        method: "get",
        params: params
    })
}


// 数据库数据备份
export const apiDataAdd = (params: any) => {
    return request({
        url: "/admin/database_bak/add",
        method: "post",
        data: params
    })
}

// 删除数据库备份信息
export const apiDeleteInfo = (params: any) => {
    return request({
        url: "/admin/database_bak/delete",
        method: "post",
        data: params
    })
}

// 还原数据库备份
export const apiRestore = (params: any) => {
    return request({
        url: "/admin/database_bak/restore",
        method: "post",
        data: params
    })
}






// ===============================================================================

// 获取商家店铺信息
export const apiGetShopInfo = (params: any) => {
    return request({
        url: "/admin/shop/info",
        method: "get",
        params: params
    })
}

// 添加店铺信息
export const apiAddShopInfo = (params: any) => {
    return request({
        url: "/admin/shop/save",
        method: "post",
        data: params
    })
}


//  获取店铺内商品详细信息

export const apiGetGoodsInfo = (params: any) => {
    return request({
        url: "/admin/goods/list",
        method: "post",
        data: params
    })
}

//  获取店铺内商品详细信息

export const apiGetShopGoodsInfo = (params: any) => {
    return request({
        url: "/admin/goods/shopGoods",
        method: "post",
        data: params
    })
}

// 上传商品图片
export const apiUploadImg = (params: any) => {
    return request({
        url: "/upload/upload_photo",
        method: "post",
        data: params,
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}

// 添加商品接口
export const apiAddGoods = (params: any) => {
    return request({
        url: "/admin/goods/save",
        method: "post",
        data: params
    })
}

// 编辑商品接口
export const apiUpdateGoods = (params: any) => {
    return request({
        url: "/admin/goods/update",
        method: "post",
        data: params
    })
}

// 删除商品
export const apiDeleteGoods = (params: any) => {
    return request({
        url: "/admin/goods/delete",
        method: "post",
        data: params
    })
}


// ===============================================================================

// 获取类别管理列表
export const apiGetTypeList = (params: any) => {
    return request({
        url: "/admin/typeinfo/list",
        method: "post",
        data: params
    })
}

// 新增类别接口
export const apiAddTypeList = (params: any) => {
    return request({
        url: "/admin/typeinfo/save",
        method: "post",
        data: params
    })
}

// 编辑类别接口
export const apiEditTypeList = (params: any) => {
    return request({
        url: "/admin/typeinfo/update",
        method: "post",
        data: params
    })
}


// 删除类别接口
export const apiDeleteTypeList = (params: any) => {
    return request({
        url: "/admin/typeinfo/delete",
        method: "post",
        data: params
    })
}





















// 前台接口 ===================================================
// 获取商品接口  -- 前台首页
export const apiGoodsAllList = (params: any) => {
    return request({
        url: "/home/index/index",
        method: "get",
        params: params
    })
}


// 必须登录才能获取到该商品的详情
export const apiGetGoodsDetail = (params: any) => {
    return request({
        url: "/home/goods/info",
        method: "get",
        params: params
    })
}

// 用户注册时，手机验证码
export const apiGetUserCode = (params: any) => {
    request({
        url: "/sms_code/send_sms_code",
        method: "get",
        params: params
    })
}



// 用户登陆
export const apiUserLogin = (params: any) => {
    return request({
        url: "/home/index/login",
        method: "post",
        data: params
    })
}


// 用户注册
export const apiUserRegister = (params: any) => {
    return request({
        url: "/home/index/register",
        method: "post",
        data: params
    })
}

// 普通用户登录时获取图片验证码
export const apiGetUserImgCode = (params: any) => {
    return request({
        url: "/captcha/generateCaptcha?vl=4&fs=25&w=140&h=40&method=homeLogin",
        method: "get",
        responseType: 'arraybuffer',
        params: params
    })
}

// 登录前台获取用户信息
export const apiGetUserInfo = (params: any) => {
    return request({
        url: "/home/index/getLoginUserInfo",
        method: "get",
        params: params
    })
}


// 添加商品到购物车
export const apiAddCart  = (params: any) => {
    return request({
        url: "/home/cart/addGoodsToCart",
        method: "post",
        data: params
    })
}

// 查看购物车列表
export const apiGetCartList = (params: any) => {
    return request({
        url: "/home/cart/getUserCartList",
        method: "get",
        params: params
    })
}

// 购物车商品减 1
export const apiReduceOne = (params: any) => {
    return request({
        url: "/home/cart/reduceOneToCart",
        method: "get",
        params: params
    })
}

// 购物车商品加 1
export const apiAddOne = (params: any) => {
    return request({
        url: "/home/cart/addOneToCart",
        method: "get",
        params: params
    })
}

// 删除购物车中的商品
export const apiDeleteShopGoods = (params: any) => {
    return request({
        url: "/home/cart/deleteGoodsToCart",
        method: "post",
        data: params
    })
}


// 用户发表评论接口
export const apiSaveComment = (params: any) => {
    return request({
        url: "/home/goodscomment/save",
        method: "post",
        data: params
    })
}

// 获取用户评论
export const apiGetComment = (params: any) => {
    return request({
        url: "/home/goodscomment/list",
        method: "post",
        data: params
    })
}

// 个人中心--自己删除评论
export const apiDeleteComment = (params: any) => {
    return request({
        url: "/home/goodscomment/delete",
        method: "post",
        data: params
    })
}

// 用户充值记录

export const apiPayLog = (params: any) => {
    return request({
        url: "/home/account/generate_pay_log",
        method: "post",
        data: params
    })
}


// 进行支付
export const apiPayMoney = (params: any) => {
    return request({
        url: "/home/pay/to_pay",
        method: "get",
        params: params
    })
}


// 修改个人信息
export const apiUpdateInfo = (params: any) => {
    return request({
        url: "/home/account/update_info",
        method: "post",
        data: params
    })
}

// 获取该用户所有的订单
export const apiGetOrderList = (params: any) => {
    return request({
        url: "/home/account/user_order_list",
        method: "get",
        params: params
    })
}

//

// 修改密码
export const apiUpdatePass = (params: any) => {
    return request({
        url: "/home/account/update_pwd",
        method: "post",
        data: params
    })
}

// 修改地址
export const apiUpdateAddress = (params: any) => {
    return request({
        url: '/home/address/update',
        method: 'post',
        data: params
    })
}

// 新增地址
export const apiAddAddress = (params: any) => {
    return request({
        url: '/home/address/save',
        method: 'post',
        data: params
    })
}

// 用户生成订单记录

export const apiGetGoodsRecord = (params: any) => {
    return request({
        url: "/home/order/generate_order",
        method: "post",
        data: params
    })
}

// 用余额进行支付
export const apiBalanceApply = (params: any) => {
    return request({
        url: "/home/order/order_pay",
        method: "get",
        params: params
    })
}






















// 获取店铺列表

export const apiGetShopList = (params: any) => {
    return request({
        url: "/admin/shop/list",
        method: "post",
        data: params
    })
}

// 获取所有订单

export const apiGetAllOrderList = (params: any) => {
    return request({
        url: "/admin/order/list",
        method: "post",
        data: params
    })
}


// 获取店铺订单

export const apiGetShopOrder = (params: any) => {
    return request({
        url: "/admin/order/orderCenter",
        method: "post",
        data: params
    })
}


// 后台查看订单详情接口
export const apiGetOrderDetail = (params: any) => {
    return request({
        url: "/admin/order/getOrderInfo",
        method: "get",
        params: params
    })
}

// 前台查看订单详情接口
export const apiGetDetail = (params: any) => {
    return request({
        url: "/home/order/get_order_detail",
        method: "get",
        params: params
    })
}


// 退出登录接口
export const apiUserLayout = (params: any) => {
    return request({
        url: "/home/index/logout",
        method: "get",
        params: params
    })
}


// 获取用户收货地址
export const apiGetUserAddress = (params: any) => {
    return request({
        url: "/home/address/info/",
        method: "get",
        params: params
    })
}

// 前台忘记密码

export const apiForgetPass = (params: any) => {
    return request({
        url: "/system/forgetPassword",
        method: "post",
        data: params
    })
}

// 修改商家个人信息

export const apiEditInfo = (params: any) => {
    return request({
        url: "/system/update_userinfo",
        method: "post",
        data: params
    })
}
